package com.md.rps.action.actions;

import com.md.rps.mybatis.model.REGISTER;
import com.md.rps.service.RegisterOperator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
public class RegisterAction {

    @Autowired
    private RegisterOperator registerOperator;

    @PostMapping("register")
    public int addRegister(REGISTER register) {
        return registerOperator.addRegister(register);
    }

    @GetMapping("findByDept")
    public List<REGISTER> findByDept(@RequestParam("deptid")int deptid) {
        return registerOperator.getRegisterByDept(deptid);
    }

    @GetMapping("userRegister")
    public List<REGISTER> getUserRegister(@RequestParam("deptid")int deptid) {
        return registerOperator.getUserRegister(deptid);
    }

    @PostMapping("called")
    public Integer called(int id) {
        return registerOperator.called(id);
    }

    @GetMapping("getMaxOrder")
    public Integer getMaxOrder(@RequestParam("doctorId")int doctorId,
                               @RequestParam("time")String time,
                               @RequestParam("timeOfDay")int timeOfDay) {
        return registerOperator.getMaxOrder(doctorId,time,timeOfDay);
    }

    @PostMapping("reCall")
    public Integer reCall(@RequestParam("id")int id, @RequestParam("newOrder")int newOrder) {
        return registerOperator.reCall(id,newOrder);
    }
}
